<template>
	<view>
		<u-navbar title="結算單" placeholder>
			<view class="flexleft" slot="left">
				<view @click="backpage">
					<u-icon name="arrow-left" color="#333333" size="20"></u-icon>
				</view>
				<view class="xiaohui margin_left1" style="font-size: 24rpx;"
					@click="jumpurl('/pages/workbench/baobiao')">查看報表</view>
			</view>
			<view class="flexright xiaohuang" slot="right">
				<view class="searchBtn2" @click="dayin">打印</view>
			</view>
		</u-navbar>
		<view class="mainpadding">
			<view class="flexcenter selecttime_box radius" @click="messageTime.timeShow=true">
				<u-icon name="calendar" color="#F8CF39" size="20"></u-icon>
				<view class="xiaohei main_size margin_left1">{{start_time || "開始時間"}}-{{end_time || "結束時間"}}</view>
			</view>
			<view class="mainpadding_top ffffff radius">
				<!-- <view class="flexcenter hei_text bold" style="font-size: 40rpx;">結算單</view> -->
				<view class="flexbetween">
					<view class="hei_text main_size bold">結算日期</view>
					<view class="huang_text main_size bold">{{dataAll.js_time}}</view>
				</view>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">結算人</view>
					<view class="huang_text main_size bold">{{dataAll.js_username}}</view>
				</view>
				<view class="hei_text main_size bold margin_top">商品訂單</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">配送</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{dataAll.ps_num}}</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{dataAll.ps_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">自取</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{dataAll.zq_num}}</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{dataAll.zq_price}}</view>
				</view>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">内用</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{dataAll.nr_num}}</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{dataAll.nr_price}}</view>
				</view>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">統計</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{Number(dataAll.ps_num)+Number(dataAll.zq_num)+Number(dataAll.nr_num)}}</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{Number(dataAll.ps_price)+Number(dataAll.zq_price)+Number(dataAll.nr_price)}}</view>
				</view>
				<template v-if="hy_type!=0">
					<view class="hei_text main_size bold margin_top">呼叫訂單</view>
					<view class="flexbetween margin_top">
						<view class="hei_text main_size bold">成交</view>
						<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{dataAll.call_cj_num}}</view>
						<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{dataAll.call_cj_price}}</view>
					</view>
					<view class="flexbetween margin_top">
						<view class="hei_text main_size bold">取消</view>
						<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{dataAll.call_qx_num}}</view>
						<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{dataAll.call_qx_price}}</view>
					</view>
					<view class="flexbetween margin_top pdl">
						<view class="hei_text main_size bold">待付</view>
						<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{dataAll.call_wf_num}}</view>
						<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{dataAll.call_wf_price}}</view>
					</view>
				</template>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">統計</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">{{Number(dataAll.call_cj_num)+Number(dataAll.call_qx_num)+Number(dataAll.call_wf_num)}}</view>
					<view class="hui_text main_size bold" style="width: 200rpx;text-align: right;">${{Number(dataAll.call_cj_price)+Number(dataAll.call_qx_price)+Number(dataAll.call_wf_price)}}</view>
				</view>
				
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">用餐人數</view>
					<view class="hui_text main_size bold">
						老人：{{dataAll.lr_num}}，大人：{{dataAll.dr_num}}，兒童：{{dataAll.xh_num}}
					</view>
				</view>
				<view class="flexright margin_top ">
					<view class="hei_text main_size bold">用餐人數統計：</view>
					<view class="hong_text main_size bold">共{{dataAll.total_ry_num}}人
					</view>
				</view>
				<!-- <view class=" xiaobai">占位</view> -->
				<view class="hei_text main_size bold margin_top">商品訂單</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">銷售商品數</view>
					<view class="hui_text main_size bold">{{dataAll.total_goods_num}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">銷售商品總數</view>
					<view class="hui_text main_size bold">{{dataAll.total_goods_buynum}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">平均客單價</view>
					<view class="hui_text main_size bold">${{dataAll.pjjdj}}</view>
				</view>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">平均商品單價</view>
					<view class="hui_text main_size bold">${{dataAll.pjspdj}}</view>
				</view>
				
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">錢包</view>
					<view class="hui_text main_size bold">${{dataAll.qb_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">現金</view>
					<view class="hui_text main_size bold">${{dataAll.xj_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">多元</view>
					<view class="hui_text main_size bold">${{dataAll.xd_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">信用卡</view>
					<view class="hui_text main_size bold">${{dataAll.xyk_price}}</view>
				</view>
				
				<!-- <view class="flexbetween margin_top">
					<view class="hei_text main_size bold">LINE PAY二維碼</view>
					<view class="hui_text main_size bold">${{dataAll.linepay_codeprice}}</view>
				</view> -->
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">LINE PAY線下</view>
					<view class="hui_text main_size bold">${{dataAll.linepay_xxprice}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">LINE PAY線上</view>
					<view class="hui_text main_size bold">${{dataAll.linepay_xsprice}}</view>
				</view>
				<!-- <view class="flexbetween margin_top">
					<view class="hei_text main_size bold">街口二維碼</view>
					<view class="hui_text main_size bold">${{dataAll.jkopay_codeprice}}</view>
				</view> -->
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">街口支付線下</view>
					<view class="hui_text main_size bold">${{dataAll.jkopay_xxprice}}</view>
				</view>
				<view class="flexbetween margin_top ">
					<view class="hei_text main_size bold">街口支付線上</view>
					<view class="hui_text main_size bold">${{dataAll.jkopay_xsprice}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">全 支 付 線下</view>
					<view class="hui_text main_size bold">${{dataAll.qxpay_codeprice}}</view>
				</view>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">全 支 付 線上</view>
					<view class="hui_text main_size bold">${{dataAll.qxpayxs_codeprice}}</view>
				</view>
				<view class="flexright margin_top pdl">
					<view class="hei_text main_size bold">合計：</view>
					<view class="hong_text main_size bold">${{dataAll.total_orderprice}}</view>
				</view>
				<!-- <view class=" xiaobai">占位</view> -->
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">優惠券</view>
					<view class="hui_text main_size bold">-${{dataAll.total_yh_price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">免運券</view>
					<view class="hui_text main_size bold">-${{dataAll.total_my_price}}</view>
				</view>
				<view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">退費</view>
					<view class="hui_text main_size bold">-${{dataAll.tui_price}}</view>
				</view>
				<!-- <view class="flexbetween margin_top pdl">
					<view class="hei_text main_size bold">票券</view>
					<view class="hui_text main_size bold">${{dataAll.total_pj_price}}</view>
				</view> -->
				<view class="flexright margin_top pdl">
					<view class="hei_text main_size bold">合計：</view>
					<view class="hong_text main_size bold">-${{dataAll.total_yhmy}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">銷售額（應稅）</view>
					<view class="hong_text main_size bold">${{dataAll.total_ysprice }}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">銷售額（零稅）</view>
					<view class="hong_text main_size bold">${{dataAll.total_lrprice}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">銷售額（免稅）</view>
					<view class="hong_text main_size bold">${{dataAll.total_lrprice}}</view>
				</view>
			</view>
		</view>
		<timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				start_time: "",
				end_time: "",
				messageTime: {
					mode: "date",
					timeShow: false,
					title: "請選擇開始時間"
					
				},
				dataAll:{},
				hy_type: "", //0買賣,1計時，3住宿露营，5工程，6超商
			}
		},
		onLoad() {
			this.hy_type = uni.getStorageSync('hy_type')
		},
		onShow() {
			this.start_time = this.http.returnDate(Number(new Date()))
			this.end_time = this.http.returnDate(Number(new Date()))
			this.init()
		},
		methods: {
			timeConfirm(e) {
				if(this.messageTime.title == "請選擇開始時間"){
					this.start_time = e
					setTimeout(()=>{
						this.messageTime.title  = "請選擇結束時間"
						this.messageTime.timeShow = true
					},100)
				}else{
					this.messageTime.title = "請選擇開始時間"
					this.end_time = e
					this.init()
				}
			},
			init() {
				let _this = this;
				let data = {
					shop_id: uni.getStorageSync("shop_id"),
					// js_starttime:this.start_time? Number(new Date(this.start_time)) / 1000:"",
					// js_endtime: this.end_time?Number(new Date(this.end_time)) / 1000:"",
					js_starttime:this.start_time,
					js_endtime: this.end_time,
				}
				let url = '/api/shop/jsdData'
				this.http.request(url, 'GET', data, false, false, true).then(res => {
					this.dataAll = res.data
				}).catch(err => {
					this.http.toast(err.msg);
				})
			},
			dayin(){
				this.http.request("/api/shop/dyJsd", 'GET', {
					shop_id: uni.getStorageSync("shop_id"),
					js_starttime:this.start_time,
					js_endtime: this.end_time,
				}, false, false, true).then(res => {
					this.http.toast(res.msg);
				}).catch(err => {
					this.http.toast(err.msg);
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.selecttime {
		width: 24rpx;
		height: 24rpx;
		background-size: 100% 100%;
	}
	
	.selecttime_text {
		font-size: 24rpx;
		font-weight: 500;
		color: #666666;
	}
	
	.selecttime_box {
		padding: 14rpx;
		border: 2rpx solid #F8CF39;
	}
	
	.leftsmall {
		width: 44rpx;
		height: 44rpx;
		border-radius: 50%;
	}
	.pdl{
		border-bottom: 2rpx dashed #333;
	}
	.searchBtn2 {
		width: 124rpx;
		height: 62rpx;
		line-height: 62rpx;
		text-align: center;
		background: linear-gradient(312deg, #F8CF39 0%, #F8DA44 100%);
		border-radius: 65rpx 65rpx 65rpx 65rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
	}
</style>